using JetBrains.Annotations;



namespace Crocodile.CsharpLanguage.Tree
{
    public abstract class CsDatum : CsDeclaration
    {
        /// <summary>
        /// Type definition.
        /// </summary>
        [CanBeNull]
        public string TypeDef;

        /// <summary>
        /// Reference to the class is this datum is an instance of our generated class.
        /// </summary>
        [CanBeNull]
        public CsClass TypeClass;

        /// <summary>
        /// Code that initializes the datum.
        /// </summary>
        [CanBeNull]
        public CsExpression DefaultValue;


        /// <summary>
        /// Type definition for code generating.
        /// </summary>
        /// <returns>type definition.</returns>
        public string GetTypeDefForGenerating()
        {
            if (TypeDef != null)
                return TypeDef;
            if (TypeClass != null)
                return TypeClass.FullName;
            return "object";
        }
    }
}